package RDFManager;

import org.apache.jena.rdf.model.Property;

import java.util.HashMap;
import java.util.Map;

/**
 * {@code PropertySet}提供RDF文件中的关系属性和数据属性，以及一个属性LocalName到RDR属性的索引表
 */
public class PropertySet {
  protected static Property property(String local) {
    return RDFReader.model.getProperty(RDFHead.namespace, local);
  }

  public static final Property hasID = PropertySet.property("hasID");
  public static final Property hasRadius = PropertySet.property("hasRadius");
  public static final Property hasHeight = PropertySet.property("hasHeight");
  public static final Property isConvex = PropertySet.property("isConvex");
  public static final Property hasTopRadius = PropertySet.property("hasTopRadius");
  public static final Property hasBottomRadius = PropertySet.property("hasBottomRadius");
  public static final Property hasMajorRadius = PropertySet.property("hasMajorRadius");
  public static final Property hasMinorRadius = PropertySet.property("hasMinorRadius");
  public static final Property hasInteriorRadius = PropertySet.property("hasInteriorRadius");
  public static final Property hasExteriorRadius = PropertySet.property("hasExteriorRadius");
  public static final Property hasFace = PropertySet.property("hasFace");
  public static final Property hasEdge = PropertySet.property("hasEdge");

  public static final Property coaxialAdjoining = PropertySet.property("coaxialAdjoining");
  public static final Property coaxialDisjoint = PropertySet.property("coaxialDisjoint");
  public static final Property coaxialContain = PropertySet.property("coaxialContain");
  public static final Property coaxialContainedBy = PropertySet.property("coaxialContainedBy");
  public static final Property coaxialPartOverlap = PropertySet.property("coaxialPartOverlap");
  public static final Property coaxialOverlap = PropertySet.property("coaxialOverlap");
  public static final Property coplanar = PropertySet.property("coplanar");
  public static final Property intersecting = PropertySet.property("intersecting");
  public static final Property perpendicular = PropertySet.property("perpendicular");
  public static final Property parallel = PropertySet.property("parallel");
  public static final Property overlapped = PropertySet.property("overlapped");


  public static final Property hasAxisEnd1_x = PropertySet.property("hasAxisEnd1_x");
  public static final Property hasAxisEnd1_y = PropertySet.property("hasAxisEnd1_y");
  public static final Property hasAxisEnd1_z = PropertySet.property("hasAxisEnd1_z");
  public static final Property hasAxisEnd2_x = PropertySet.property("hasAxisEnd2_x");
  public static final Property hasAxisEnd2_y = PropertySet.property("hasAxisEnd2_y");
  public static final Property hasAxisEnd2_z = PropertySet.property("hasAxisEnd2_z");
  public static final Property hasAxisVector_x = PropertySet.property("hasAxisVector_x");
  public static final Property hasAxisVector_y = PropertySet.property("hasAxisVector_y");
  public static final Property hasAxisVector_z = PropertySet.property("hasAxisVector_z");
  public static final Property hasCentralPoint_x = PropertySet.property("hasCentralPoint_x");
  public static final Property hasCentralPoint_y = PropertySet.property("hasCentralPoint_y");
  public static final Property hasCentralPoint_z = PropertySet.property("hasCentralPoint_z");
  public static final Property hasNormalVector_x = PropertySet.property("hasNormalVector_x");
  public static final Property hasNormalVector_y = PropertySet.property("hasNormalVector_y");
  public static final Property hasNormalVector_z = PropertySet.property("hasNormalVector_z");
  public static final Property hasEnd1_x = PropertySet.property("hasEnd1_x");
  public static final Property hasEnd1_y = PropertySet.property("hasEnd1_y");
  public static final Property hasEnd1_z = PropertySet.property("hasEnd1_z");
  public static final Property hasEnd2_x = PropertySet.property("hasEnd2_x");
  public static final Property hasEnd2_y = PropertySet.property("hasEnd2_y");
  public static final Property hasEnd2_z = PropertySet.property("hasEnd2_z");
  public static final Property hasDirectionVector_x = PropertySet.property("hasDirectionVector_x");
  public static final Property hasDirectionVector_y = PropertySet.property("hasDirectionVector_y");
  public static final Property hasDirectionVector_z = PropertySet.property("hasDirectionVector_z");


  private static final Map<String, Property> propertyMap = new HashMap<String, Property>();

  static {
    propertyMap.put("hasAxisEnd1_x", hasAxisEnd1_x);
    propertyMap.put("hasAxisEnd1_y", hasAxisEnd1_y);
    propertyMap.put("hasAxisEnd1_z", hasAxisEnd1_z);
    propertyMap.put("hasAxisEnd2_x", hasAxisEnd2_x);
    propertyMap.put("hasAxisEnd2_y", hasAxisEnd2_y);
    propertyMap.put("hasAxisEnd2_z", hasAxisEnd2_z);
    propertyMap.put("hasAxisVector_x", hasAxisVector_x);
    propertyMap.put("hasAxisVector_y", hasAxisVector_y);
    propertyMap.put("hasAxisVector_z", hasAxisVector_z);
    propertyMap.put("hasCentralPoint_x", hasCentralPoint_x);
    propertyMap.put("hasCentralPoint_y", hasCentralPoint_y);
    propertyMap.put("hasCentralPoint_z", hasCentralPoint_z);
    propertyMap.put("hasNormalVector_x", hasNormalVector_x);
    propertyMap.put("hasNormalVector_y", hasNormalVector_y);
    propertyMap.put("hasNormalVector_z", hasNormalVector_z);
    propertyMap.put("hasEnd1_x", hasEnd1_x);
    propertyMap.put("hasEnd1_y", hasEnd1_y);
    propertyMap.put("hasEnd1_z", hasEnd1_z);
    propertyMap.put("hasEnd2_x", hasEnd2_x);
    propertyMap.put("hasEnd2_y", hasEnd2_y);
    propertyMap.put("hasEnd2_z", hasEnd2_z);
    propertyMap.put("hasDirectionVector_x", hasDirectionVector_x);
    propertyMap.put("hasDirectionVector_y", hasDirectionVector_y);
    propertyMap.put("hasDirectionVector_z", hasDirectionVector_z);

    propertyMap.put("coaxialAdjoining", coaxialAdjoining);
    propertyMap.put("coaxial_adjoining", coaxialAdjoining);
    propertyMap.put("coaxialDisjoint", coaxialDisjoint);
    propertyMap.put("coaxial_separate", coaxialDisjoint);
    propertyMap.put("coaxialContain", coaxialContain);
    propertyMap.put("coaxial_contain", coaxialContain);
    propertyMap.put("coaxialContainedBy", coaxialContainedBy);
    propertyMap.put("coaxial_containedBy", coaxialContainedBy);
    propertyMap.put("coaxialPartOverlap", coaxialPartOverlap);
    propertyMap.put("coaxial_partOverlap", coaxialPartOverlap);
    propertyMap.put("coaxialOverlap", coaxialOverlap);
    propertyMap.put("coaxial_overlap", coaxialOverlap);
    propertyMap.put("coplanar", coplanar);
    propertyMap.put("intersecting", intersecting);
    propertyMap.put("intersect", intersecting);
    propertyMap.put("perpendicular", perpendicular);
    propertyMap.put("parallel", parallel);
    propertyMap.put("overlapped", overlapped);

  }

  /**
   * 根据属性的LocalName返回RDF属性表示
   *
   * @param propertyName 输入属性的LocalName
   * @return {@code Property property}RDF属性对象
   */
  public static Property getProperty(String propertyName) {
    if (propertyMap.containsKey(propertyName)) {
      return propertyMap.get(propertyName);
    } else {
      System.err.println("Property not found: " + propertyName);
      return null;
    }
  }
}
